package com.njtoyo.taxi.admin.logic.business.driver;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.njtoyo.taxi.admin.mapper.master.entity.DriverRegionServiceArrangement;
import com.njtoyo.taxi.admin.mapper.master.enums.DriverRegionServiceArrangementCategory;
import com.njtoyo.taxi.admin.mapper.master.mapper.DriverRegionServiceArrangementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DriverRegionServiceArrangementLogic {
    @Autowired
    private DriverRegionServiceArrangementMapper driverRegionServiceArrangementMapper;

    public Boolean isOpen(Long driverRegionId, DriverRegionServiceArrangementCategory serviceCategory) {
        return new LambdaQueryChainWrapper<>(driverRegionServiceArrangementMapper)
                .eq(DriverRegionServiceArrangement::getDriverRegionId, driverRegionId)
                .eq(DriverRegionServiceArrangement::getServiceCategory, serviceCategory)
                .eq(DriverRegionServiceArrangement::getIsOpen, true)
                .count() > 0;
    }
}
